package com.ming.transaction.exception;

import com.ming.transaction.common.Result;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author: Chenming
 * @date 2023/5/3 23:11
 */
@ControllerAdvice(basePackages = "com.ming.transaction.controller")
public class GlobalExceptionHandle {

    @ExceptionHandler(ServiceException.class)
    @ResponseBody
    public Result handle(ServiceException ex){
        return Result.fail(ex.getCode(), ex.getMessage());
    }

}
